<template>
  <Card title="个人信息" :shadow="true">
    <div class="site-wrap">
      <div class="site-author site-overview-item">
        <div class="site-author-image">
          <img :src="userInfo.avatar" alt="用户头像" />
        </div>
        <div class="site-author-name">{{ userInfo.name }}</div>
        <div class="site-author-desc">{{ userInfo.signature }}</div>
      </div>
      <div class="site-author-links site-overview-item">
        <div v-for="(link, index) in links" :key="index" class="links-item">
          <span class="count">{{ link.count }}</span>
          <span class="name">{{ link.title }}</span>
        </div>
      </div>
    </div>
  </Card>
</template>

<script>
import { reactive, computed } from 'vue'
import Card from '@/components/base/Card/index.vue'
export default {
  name: 'UserInfo',
  props: {
    statisticsInfo: {
      type: Object,
      default: () => {
        return {
          articleCount: 0,
          tagCount: 0,
          typeCount: 0
        }
      }
    }
  },
  components: {
    Card,
  },
  setup(props) {
    const links = computed(() => {
      return [
        {
          title: '文章',
          count: props.statisticsInfo.articleCount || 0,
        },
        {
          title: '分类',
          count: props.statisticsInfo.typeCount || 0,
        },
        {
          title: '标签',
          count: props.statisticsInfo.tagCount || 0,
        },
      ]
    })
    const userInfo = reactive({
      avatar: 'https://blog-la.oss-cn-hangzhou.aliyuncs.com/blog/assets/avatar.jpeg',
      name: '迷之de小孩灬',
      signature: '不要让世界左右你的情绪，也不要让情绪左右你的理性！',
    })
    return {
      links,
      userInfo,
    }
  },
}
</script>

<style lang="less">
.site-wrap {
  .site-overview-item:not(:first-child) {
    margin-top: 10px;
    padding-top: 10px;
  }
  .site-author {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    &-image {
      width: 120px;
      height: 120px;
      img {
        width: 100%;
        height: 100%;
        border: 1px solid #eee;
        padding: 2px;
        transition: transform 1s ease-out;
        border-radius: 50%;
        &:hover {
          transform: rotateZ(360deg);
        }
      }
    }
    &-name {
      font-size: 16px;
      font-weight: bold;
      padding: 10px 0;
    }
    &-desc {
      color: #666;
      font-size: 13px;
      text-align: center;
    }
  }
  .site-author-links {
    display: flex;
    justify-content: space-around;
    align-items: center;
    .links-item {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      cursor: pointer;
      .icon {
        width: 30px;
        height: 30px;
        border-radius: 50%;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 24px;
      }
      .name {
        color: #666;
        font-size: 12px;
      }
      .count {
        color: #333;
        font-size: 16px;
      }
    }
  }
}
</style>
